<template>
	<a-layout :title="parm.name" :status="status">
		<y-form radius="radius" :keys="columns" v-model="parm" @submit="submit" submitText="保存设置" />
	</a-layout>
</template>

<script>
	import yForm from "@/y-ui/y-form/y-form.vue";
	export default {
		components: {
			yForm
		},
		onLoad(e) {
			this.parm = e;
		},
		data() {
			return {
				parm: {},
				config: [{
					lable: "设备ID:",
					key: 'id'
				}, {
					lable: '状态:',
					key: 'statusNaem'
				}]
			}
		},
		computed: {
			status() {
				const {
					status,
					statusName
				} = this.parm;
				return {
					title: statusName,
					color: status === 'false' ? '#ff5500' : "#00aa00"
				}
			},
			columns() {
				return [{
						type: 'yPicker',
						key: '1',
						lable: '地点标签：',
						placeholder: '请选择',
						range: [{
							name: '门口',
							id: "2"
						}],
						rangeKey: 'name',
						valueKey: 'id',
						rules: {
							rule: ['required'],
							msg: ['请选择']
						}
					},
					{
						type: 'yCheckbox',
						key: '2',
						lable: '应用场景：',
						rangeKey: 'name',
						valueKey: 'value',
						range: [{
								value: '1',
								name: '门禁'
							},
							{
								value: '2',
								name: '考勤'
							},
							{
								value: '3',
								name: '会议'
							}
						],
						rules: {
							rule: ['required'],
							msg: ['必选']
						}
					},
					{
						type: 'yCheckbox',
						key: '23',
						lable: '使用人：',
						rangeKey: 'name',
						valueKey: 'value',
						range: [{
								value: '1',
								name: '老师'
							},
							{
								value: '2',
								name: '学生'
							}
						],
						rules: {
							rule: ['required'],
							msg: ['必选']
						}
					},
					{
						type: 'yRadio',
						key: '44',
						lable: '是否重新下发人脸：',
						rangeKey: 'name',
						valueKey: 'value',
						range: [{
								value: 1,
								name: '是'
							},
							{
								value: 0,
								name: '否',
							}
						],
						rules: {
							rule: ['required'],
							msg: ['必选']
						}
					},
				];
			}
		},
		methods: {
			submit(e) {
				if (!e) return;
				this.$http.post('', this.parm).then(res => {

				});
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #fff;
	}

	.checkbox {
		font-size: 28rpx;
		margin-left: 1em;
	}
</style>
